package com.neosoft.tutorials;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class DrawingImagesTutorial implements ApplicationListener {

	private SpriteBatch batch;
	
	@Override
	public void create() {
		this.batch = new SpriteBatch();
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

	@Override
	public void render() {
		this.drawTexture(this.batch);
		this.drawTextureRegion(this.batch);
		this.drawSprite(this.batch);
	}

	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}
	
	private void drawTexture(SpriteBatch batch) {
		Texture texture = new Texture("badlogic.jpg");
		final int x = 20;
		final int y = 20;		
		
		batch.begin();
		batch.draw(texture, x, y);
		batch.end();
	}
	
	private void drawTextureRegion(SpriteBatch batch) {
		Texture texture = new Texture("badlogic.jpg");
		TextureRegion region = new TextureRegion(texture, 20, 20, 50, 50);
		final int x = 300;
		final int y = 20;		
		
		batch.begin();
		batch.draw(region, x, y);
		batch.end();
	}
	
	private void drawSprite(SpriteBatch batch) {
		Texture texture = new Texture("badlogic.jpg");
		Sprite sprite = new Sprite(texture, 40, 40, 50, 50);
		final int x = 380;
		final int y = 20;
		final int degrees = 45;
		
		sprite.setPosition(x, y);
		sprite.setRotation(degrees);
		
		batch.begin();
		sprite.draw(batch);
		batch.end();
	}

}
